/* 
1.分析网页获取数据
2.存数据
*/
const https = require('https')
const fs = require('fs')

// let url = 'https://www.bilibili.com/'
let url = 'https://ai.taobao.com/?pid=mm_131341970_42698365_258142393&u=0'
https.get(url, res => {
  // 接口返回数据为片段传入，每次传入片段时会执行回调函数
  let data = ''
  res.on('data', chunk => {
    data += chunk
  })

  res.on('end', () => {
    fs.writeFileSync('./taobao.html', data)
    console.log('数据传输完毕')
  })

}).on('error', err => {
  console.log('请求失败');
  console.log(err);
})